package com.xl.recognize;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * JdkVersion: 1.8
 * Author: lei·xie
 * Created: 2024/8/2 0002 15:22
 * Description: 基础认识
 */
@Slf4j(topic = "c.Test3")
public class ThreadDemo03 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        /*FutureTask<Integer> task3 = new FutureTask<>(new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                log.debug("hello");
                return 100;
            }
        });*/
        FutureTask<Integer> task3 = new FutureTask<>(() -> {log.debug("hello"); return 100;});
        new Thread(task3, "t3").start();
        Integer result = task3.get();
        log.debug("结果是：{}",result);
    }
}
